<template>
  <el-card class="box-card el-card-flex">
    <div slot="header" class="clearfix">
      <span>{{headLine}}</span>
    </div>
    <div class="text item el-over-auto el-card-flex">
      <el-form :model='formData' :inline="true" ref='formData' label-width="150px">
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织基本信息
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="组织档案编码:">
              <el-input placeholder="自动生成组织档案编码" v-model="formData.orgCode" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="组织注册ID:" prop="id">
              <el-input placeholder="请填写组织注册ID" v-model="formData.id"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col>
            <el-form-item label="组织分类:" prop="orgType" :rules="{required: true, message: '请选择组织分类'}">
              <el-radio-group v-model="formData.orgType">
                <el-radio :label="item.id" v-for="item in orgTypeData" :key='item.id'>{{item.name}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="组织名称:" prop="name" :rules="{required: true, message: '请填写组织名称'}">
              <el-input placeholder="请输入组织名称" v-model="formData.name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="简称:">
              <el-input placeholder="请填写简称" v-model="formData.alias"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="曾用名:">
              <el-input placeholder="请输入曾用名" v-model="formData.historyNames"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="英文名:">
              <el-input placeholder="请输入英文名" v-model="formData.property3"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="全称:">
              <el-input placeholder="请输入全称" v-model="formData.fullName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织注册信息
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="社会统一信用代码:" prop="creditCode" :rules="{required: true, message: '请填写社会统一信用代码'}">
              <el-input placeholder="请输入社会统一信用代码" v-model="formData.creditCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="组织机构代码:">
              <el-input placeholder="请填写组织机构代码" v-model="formData.orgNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="纳税人识别号:">
              <el-input placeholder="请输入纳税人识别号" v-model="formData.taxNumber"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="企业状态:" prop="regStatus" :rules="{required: true, message: '请填选择企业状态'}">
              <el-select class='input-width' placeholder="企业状态" v-model="formData.regStatus">
                <el-option v-for="item in companyStatus" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注册号:">
              <el-input placeholder="请输入注册号" v-model="formData.regNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注册资本:">
              <el-input placeholder="请输入注册资本" v-model="formData.regCapital"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="注册资本币种:">
              <el-input placeholder="请输入注册资本币种" v-model="formData.regcapitalCurrency"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="公司类型:">
              <el-select class='input-width' placeholder="公司类型" v-model="formData.companyOrgType">
                <el-option v-for="item in companyType" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="实收注册资金:">
              <el-input placeholder="请输入实收注册资金" v-model="formData.actualCapital"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="实收注册资本币种:">
              <el-input placeholder="请输入实收注册资本币种" v-model="formData.actualCapitalCurrency"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="登记机关:">
              <el-input placeholder="请填写登记机关" v-model="formData.regInstitute"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="国别或地区:">
              <el-select class='input-width' placeholder="请选择国别或地区" v-model="formData.zone">
                <el-option v-for="item in zoneData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="省份简称:">
              <el-input placeholder="请输入省份简称" v-model="formData.base"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注册地址:">
              <el-input placeholder="请填写注册地址" v-model="formData.regLocation"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织简介
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="企业标签:">
              <el-input placeholder="请输入企业标签" v-model="formData.tags"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="企业评分:">
              <el-input placeholder="请输入企业评分(万分制)" v-model="formData.percentileScore"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="小微企业:">
              <el-radio-group v-model="formData.isMicroEnt">
                <el-radio :label="0">是</el-radio>
                <el-radio :label="1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="法人类型:">
              <el-radio-group v-model="formData.type">
                <el-radio :label="1">自然人</el-radio>
                <el-radio :label="2">公司</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="法人:">
              <el-input placeholder="请输入法人" v-model="formData.legalPersonName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="法人身份证:">
              <el-input placeholder="请输入法人身份证" v-model="formData.legalPersonId"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="人员规模:">
              <el-input placeholder="请输入人员规模" v-model="formData.staffNumRange"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="参保人数:">
              <el-input placeholder="请输入参保人数" v-model="formData.socialStaffNum"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="行业:">
              <el-input placeholder="请输入行业" v-model="formData.industry"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="股票类型:">
              <el-select class='input-width' placeholder="股票类型" v-model="formData.bondType">
                <el-option v-for="item in bondTypeDatas" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="股票号:">
              <el-input placeholder="请输入股票号" v-model="formData.bondNum"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="股票名:">
              <el-input placeholder="请填写股票名" v-model="formData.bondName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="股票曾用名:">
              <el-input placeholder="请填写股票曾用名" v-model="formData.usedBondName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="成立日期:">
              <el-date-picker class='input-width' v-model="formData.estiblishTime" type="date" placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日" value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="核准时间:">
              <el-date-picker class='input-width' v-model="formData.approvedTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="经营开始时间:">
              <el-date-picker class='input-width' v-model="formData.fromTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="经营结束时间:">
              <el-date-picker class='input-width' v-model="formData.toTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="吊销日期:">
              <el-date-picker class='input-width' v-model="formData.revokeDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="吊销原因:">
              <el-input placeholder="请填写吊销原因" v-model="formData.revokeReason"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注销日期:">
              <el-date-picker class='input-width' v-model="formData.cancelDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注销原因:">
              <el-input placeholder="请填写注销原因" v-model="formData.cancelReason"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="登记注册类型:">
              <el-select class='input-width' placeholder="登记注册类型" v-model="formData.orgCat">
                <el-option v-for="item in subOrgReqCatData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务板块:">
              <el-select class='input-width' placeholder="业务板块" v-model="formData.bizCat">
                <el-option v-for="item in subOrgPlateData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="网站网址:">
              <el-input v-model="formData.webUrl" placeholder="请填写网站网址"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col>
            <el-form-item label="经营范围:">
              <el-input style="width: 500px;" size="large" type="textarea" :rows="3" placeholder="请填写经营范围" v-model="formData.businessScope"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>联系方式
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="邮编:">
              <el-input v-model="formData.zipCode" placeholder="请输入邮编"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="电子邮箱:">
              <el-input v-model="formData.email" placeholder="请输入电子邮箱"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系人:">
              <el-input v-model="formData.linkMan" placeholder="请填写联系人"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8">
            <el-form-item label="联系电话:">
              <el-input v-model="formData.lintel" placeholder="请填写联系电话"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div style="text-align: right;margin-right: 8px;margin-bottom: 8px;margin-top: 8px;">
      <el-button type="primary" @click="archivesSave('formData')">保存 <i class="el-icon-document-checked"></i>
      </el-button>
      <el-button type="danger" @click="archivesEvt()">关闭 <i class="el-icon-close"></i>
      </el-button>
    </div>
  </el-card>
</template>
<script>
  import {
    Dialog,
    Table,
    TableColumn,
    Pagination,
    MessageBox,
    Message,
    Divider,
    datePicker
  } from 'element-ui'
  import {
    archiveAdd, //组织档案新增
    archiveEdit, //组织档案编辑
  } from '@/api/org/orgnizationArchives/addEditOrgnizatonArchives.js'
  import {
    comboBoxDataSelect, //下拉通用接口
  } from '@/api/org/orgnizationArchives/orgnizationArchives.js'
  export default {
    name: "addEditOrgnizatonArchives",
    components: {
      'el-dialog': Dialog, // 对话框
      'el-table': Table, // 表格
      'el-table-column': TableColumn, // 表格列
      'el-pagination': Pagination, // 分页
      'el-divider': Divider, //分割线
      'el-date-picker': datePicker, //日期选择器
    },
    data() {
      return {
        formData: {}, //表单
        headLine: '', //标题
        orgTypeData: [], //组织类型
        companyStatus: [], //企业状态
        companyType: [], //公司类型
        zoneData: [], //国别或地区
        bondTypeDatas: [], //股票类型
        subOrgReqCatData: [], //登记注册类型
        subOrgPlateData: [], //业务板块
      }
    },
    created() {
      this.headLine = this.$route.params.row.title
      if (this.headLine == '编辑') {
        this.formData = this.$route.params.row
      }
      this.getsubOrgCat()
      this.getCompanyStatus()
      this.getCompanyType()
      this.getZone()
      this.getBondType()
      this.getBondType()
      this.getSubOrgCat()
      this.getSubOrgPlate()
    },
    methods: {
      getsubOrgCat() { //组织类型
        comboBoxDataSelect('c937124a153a4ad2953b690733175f6f').then(res => {
          if (res.data.code == 10000) {
            this.orgTypeData = res.data.data
          }
        })
      },
      getCompanyStatus() { //获取企业状态
        comboBoxDataSelect('3a3e807fb3de4652b6c79572f993b903').then(res => {
          if (res.data.code == 10000) {
            this.companyStatus = res.data.data
          }
        })
      },
      getCompanyType() { //获取公司类型
        comboBoxDataSelect('8bbc223e0a444d049d32485e83c19580').then(res => {
          if (res.data.code == 10000) {
            this.companyType = res.data.data
          }
        })
      },
      getZone() { //获取国别或地区
        comboBoxDataSelect('99c3b662fabc46e28a924134fd4a2f28').then(res => {
          if (res.data.code == 10000) {
            this.zoneData = res.data.data
          }
        })
      },
      getBondType() { //获取股票类型
        comboBoxDataSelect('78b4ad0dd6384f0c9ba55ef30671a72c').then(res => {
          if (res.data.code == 10000) {
            this.bondTypeDatas = res.data.data
          }
        })
      },
      getSubOrgCat() { //获取登记注册类型
        comboBoxDataSelect('84da22743c194f7f9f6d3e9f773a4912').then(res => {
          if (res.data.code == 10000) {
            this.subOrgReqCatData = res.data.data
          }
        })
      },
      getSubOrgPlate() { //获取业务板块
        comboBoxDataSelect('494d92fc6f8c41e48e62f7cc11f1ec67').then(res => {
          if (res.data.code == 10000) {
            this.subOrgPlateData = res.data.data
          }
        })
      },
      archivesSave(formName) { //保存
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let data = this.formData
            if (this.headLine == '新增') {
              archiveAdd(data).then(res => {
                if (res.data.code == 10000) {
                  Message({
                    type: 'success',
                    message: '保存成功！'
                  })
                  this.$router.go(-1)
                }
              })
            } else {
              archiveEdit(data).then(res => {
                if (res.data.code == 10000) {
                  Message({
                    type: 'success',
                    message: '保存成功！'
                  })
                  this.$router.go(-1)
                }
              })
            }
          }
        })
      },
      archivesEvt() { //关闭
        this.$router.go(-1)
      },
    }
  }
</script>
<style lang="scss">
  .basic-info {
    font-size: 14px;
    line-height: 32px;
    color: #303133;
    font-weight: 700
  }

  .code-first-row {
    margin-bottom: 6px;
  }

  .line-style {
    width: 2px;
    height: 8px;
    background: #409EFF;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
  }

  .code-first-row {
    margin-bottom: 6px;
  }

  .input-width {
    width: 200px !important;
  }
</style>
